<!doctype html>
{php}
$static = '/static/home/';
{/php}
<!--[if IE 7]> <html lang="en" class="ie7"> <![endif]-->
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
<head>
    <meta charset="utf-8" />
    <title>{$siteConfig['seo_title']}</title>
    <meta name="apple-mobile-web-app-title" content="{$siteConfig['seo_title']}">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="{$static}images/favicon.ico">
    <link href="{$static}css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="{$static}css/icons.min.css" rel="stylesheet" type="text/css" />
    <link href="{$static}css/app.min.css" rel="stylesheet" type="text/css" />
    <link href="{$static}css/style.css" rel="stylesheet" type="text/css" />
</head>

<body data-sidebar="dark">

<!-- Begin page -->
<div id="layout-wrapper">

    {include file='public/mine_topbar' /}
    {include file='public/mine_left' /}

    <!-- ============================================================== -->
    <!-- Start right Content here -->
    <!-- ============================================================== -->
    <div class="main-content">

        <div class="page-content">
            <div class="container-fluid">

                <!-- start page title -->
                <div class="row">
                    <div class="col-12">
                        <div class="page-title-box d-flex align-items-center justify-content-between">
                            <h4 class="mb-0 font-size-18">添加域名</h4>

                            <div class="page-title-right">
                                <ol class="breadcrumb m-0">
                                    <li class="breadcrumb-item"><a href="javascript: void(0);">鹰眼短链</a></li>
                                    <li class="breadcrumb-item">域名管理</li>
                                    <li class="breadcrumb-item active">添加域名</li>
                                </ol>
                            </div>

                        </div>
                    </div>
                </div>
                <!-- end page title -->

                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <form class="js-ajax-from" method="post">
                                    <p class="card-title-desc">添加配置新域名</p>
                                    <div class="row form-group">
                                        <label class="col-xl-1 col-md-6 col-form-label">http协议</label>
                                        <div class="col-xl-8 col-md-6">
                                            <select class="form-control custom-select" name="httpProtocol">
                                                <option value='https'>https</option>
                                                <option value='http'>http</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="col-xl-1 col-md-6 col-form-label">域 名:</label>
                                        <div class="col-xl-8 col-md-6">
                                            <input type="text" class="form-control" name="domainName" placeholder="请输入域名，例如：www.a.com" />
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="col-xl-1 col-md-6 col-form-label">pem证书:</label>
                                        <div class="col-xl-8 col-md-6">
                                            <textarea class="form-control" name="httpsPem" rows="8"></textarea>
                                            <em for="domainName" class="invalid"></em>
                                        </div>
                                    </div>
                                    <div class="row form-group">
                                        <label class="col-xl-1 col-md-6 col-form-label">key证书:</label>
                                        <div class="col-xl-8 col-md-6">
                                            <textarea class="form-control" name="httpsKey" rows="8"></textarea>
                                            <em for="domainName" class="invalid"></em>
                                        </div>
                                    </div>

                                    <div class="row form-group">
                                        <label class="col-xl-1 col-md-6 col-form-label"></label>
                                        <div class="col-xl-8 col-md-6">
                                            <button type="submit" class="btn btn-primary btn-block waves-effect">确认添加</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- end row -->

            </div> <!-- container-fluid -->
        </div>
        <!-- End Page-content -->

    </div>
    <!-- end main content-->

</div>
<!-- END layout-wrapper -->

<!-- JAVASCRIPT -->
<script src="{$static}libs/jquery/jquery.min.js"></script>
<script src="{$static}libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="{$static}libs/metismenu/metisMenu.min.js"></script>
<script src="{$static}libs/simplebar/simplebar.min.js"></script>
<script src="{$static}libs/node-waves/waves.min.js"></script>
<script src="{$static}libs/layer/layer.js"></script>

<script src="{$static}js/pages/jquery.validate.min.js"></script>
<script src="{$static}js/app.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $(".js-ajax-from").validate({
            rules: {
                domainName: {
                    required: true,
                }
            },
            messages: {
                domainName: {
                    required: "请输入域名",
                }
            },
            submitHandler: function() {
                $.ajax({
                    url: "{:url('domain/operateAjax')}",
                    type: "POST",
                    data: $(".js-ajax-from").serialize(),
                    dataType: 'json',
                    async: true,
                    success: function (res) {
                        if (res.errorCode === 200) {
                            window.location.href = "{:url('domain/index')}";
                        } else {
                            layer.alert(res.message, {
                                title: '提示',
                                icon: 2
                            });
                        }
                    }
                });
            },
            errorPlacement: function(error, element) {
                error.insertAfter(element.parent());
            }
        });
    });
</script>
</body>
</html>